#ifndef DX11BASE_H
#define DX11BASE_H

#pragma once

#include <D3D11.h>
#include <D3DX11.h>
#include <DxErr.h>
#include <D3Dcompiler.h>
#include <dinput.h>

#define KEYDOWN(name, key)( name[key] & 0x80 )
#define BUTTONDOWN(device, key)( device.rgbButtons[key] & 0x80 )


class Dx11Base
{
public:
  Dx11Base(void);
  virtual ~Dx11Base(void);

  bool Initialize(HINSTANCE hInstance, HWND hwnd);
  void Shutdown();

  virtual bool LoadContent() = 0;
  virtual void UnloadContent() = 0;

  virtual void Update(float dt) = 0;
  virtual void Render() = 0;
  bool CompileD3DShader(char* filePath, char *entry, char* shaderModel, ID3DBlob** buffer);
protected:
  HINSTANCE m_hInstance;
  HWND m_hwnd;

  D3D_DRIVER_TYPE m_driverType;
  D3D_FEATURE_LEVEL m_featureLevel;

  ID3D11Device* m_d3dDevice;
  ID3D11DeviceContext* m_d3dContext;
  IDXGISwapChain* m_swapChain;
  ID3D11RenderTargetView* m_backBufferTarget;
  
  ID3D11DepthStencilView* m_depthStencilView;
  ID3D11Texture2D* m_depthTexture;

  LPDIRECTINPUT8 m_directInput;

  LPDIRECTINPUTDEVICE8 m_keyboardDevice;
  LPDIRECTINPUTDEVICE8 m_mouseDevice;

  char m_keyboardKeys[256];
  char m_prevKeyboardKeys[256];

  DIMOUSESTATE m_mouseState;
  DIMOUSESTATE m_prevMouseState;
  long m_mousePosX;
  long m_mousePosY;
  long m_mouseWheel;
};

#endif